package com.examination.system.instructor.dao;

import com.examination.system.instructor.dao.mysql.BaseDynamicSqlProvider;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 寇淇芮
 * @Date 2019/10/14 22:07
 */
@Mapper
@ResponseBody
public interface BaseMapper<T> {

    @SelectProvider(type = BaseDynamicSqlProvider.class, method = "pageselect")
    Page<T> selectAllPage(@Param("entity")T entity);

    @SelectProvider(type = BaseDynamicSqlProvider.class, method = "selectAll")
    List<T> selectAll();

    @SelectProvider(type = BaseDynamicSqlProvider.class,method = "selectById")
    T selectById(String id);

    @SelectProvider(type = BaseDynamicSqlProvider.class,method = "selectById")
    List<T> selectListById(String id);

    @DeleteProvider(type= BaseDynamicSqlProvider.class,method = "delectById")
     Integer delectById(@Param("id") String id);

    @DeleteProvider(type = BaseDynamicSqlProvider.class, method = "delete")
    Integer delete(T entity);

    @UpdateProvider(type=BaseDynamicSqlProvider.class,method="update")
    Integer update(@Param("entity") T entity,@Param("id") String id);

    @InsertProvider(type = BaseDynamicSqlProvider.class,method = "saver")
    Integer saver(@Param("entity") T entity);
}
